package com.runtime.hongyunmanage.controller;

import com.runtime.hongyunmanage.config.AuthFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<AuthFilter> authFilterRegistration() {
        FilterRegistrationBean<AuthFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new AuthFilter());
        registration.addUrlPatterns("/*"); // 拦截所有请求

        // 排除静态资源路径
        registration.addInitParameter("exclusions", "/js/*,/css/*,/images/*,/login.html,/register.html,/code");
        // 或者使用更灵活的方式（如正则表达式）

        return registration;
    }
}